/*
 * @Author: xiaosihan 
 * @Date: 2024-09-06 21:18:56 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2025-01-15 22:23:56
 */


import hashHistory from "@hashHistory";
import { Button } from "antd";
import { autorun } from "mobx";
import { ReactNode, useEffect, useRef, useState } from "react";
import { Ray, Triangle, Vector3 } from "three";
import OctreTest from "./OctreeTest.worker?worker";
import { Octree } from "three/examples/jsm/math/Octree";

interface Iprops {
    children?: ReactNode
}
const octreTestWorker = new OctreTest();
const octree = new Octree();
const ray = new Ray(new Vector3(), new Vector3(1, 1, 1));

octreTestWorker.onmessage = (e: MessageEvent) => {
    console.log(e.data);
    const octreeData = e.data as object;
    const inset = octree.rayIntersect.call(octreeData, ray);
    debugger;
}
// 八叉树分析工具
export default function OctreeDemo(props: Iprops) {

    const dom = useRef<HTMLDivElement | null>(null);
    const [data, setData] = useState({});

    const a = () => {
        octreTestWorker.postMessage({
            origin: new Vector3(),
            direction: new Vector3(1, 1, 1)
        });
    }

    useEffect(() => {


    }, []);

    useEffect(() => autorun(() => {

    }), []);

    return (
        <div ref={dom} >
            <Button
                onClick={() => hashHistory.push("/")}
            >
                返回首页
            </Button>
            <Button loading={true}  > </Button>
            <Button onClick={() => a()} >a</Button>
        </div>
    );

}